<?php
@session_start();

require_once("../../class/mysql.class.php");

  $obj = new Mysql();
  
  $obj -> set_table('user_login');
  $obj -> set_colone("(`*`)");
  $obj -> set_variables(" id_login = '" . $_SESSION["id"] . "' ");
  $user = $obj -> select_enregistrement();
  echo $user['id_login'];
  
if (isset($_REQUEST['add_unite']))
{
	$nom = addslashes($_REQUEST["name_unite"]); 
	$prenom = addslashes($_REQUEST["prenom_unite"]); 
	$raison_social = addslashes($_REQUEST["raison"]); 
	$tel = addslashes($_REQUEST["tel"]); 
	$fax = addslashes($_REQUEST["fax"]); 
	$email = addslashes($_REQUEST["email"]); 
		$req="SELECT * FROM `st_att_unite` WHERE nom_unite='".$nom."' AND prenom_unite='".$prenom."' AND raison_social='".$raison_social."' AND email_unite='".$email."'";
		$num = mysql_num_rows(mysql_query($req));
		if($num < 1){
		$sql = "INSERT INTO `st_att_unite` (`id_unite`, `nom_unite`, `prenom_unite`, `raison_social`, `tel_unite`, `fax_unite`, `email_unite`, `date_ajout`, `description`) 
		VALUES 
		('', '".$nom."', '".$prenom."', '".$raison_social."', '".$tel."', '".$fax."', '".$email."', '".date("y-m-d")."', '".$_POST["description"]."');";
		mysql_query($sql);
	header('location:../../list_unite.php?action=added&name='.$nom.' '.$prenom);
		
		}else{
	header('location:../../list_unite.php?action=addedError');
	}
}
